buildType=$1

basePath="/Users/weli/WorkSpace/mateurp"
projectPath=${basePath}/mateurp
frameworkPath=${projectPath}/Build/UnitySDK
substring=$(date "+%Y-%m-%d_%H-%M-%S")
obsutil="/Users/weli/WorkSpace/jenkins/obsutil/obsutil"

XCodeFileName=output_framework_$substring.zip

IPV4=$(/sbin/ifconfig en0 | grep 'inet ' | awk '{print $2}')

source_zipPath=/Users/weli/WorkSpace/Web/$XCodeFileName

preserveStr=output_framework_$(date "+%Y-%m-%d")
files=$(find /Users/weli/WorkSpace/Web -type f -name "output_framework*")

for file in $files
do
    if [[ "$(basename $file)" != "${preserveStr}*" ]];then
        echo "remove $file"
        rm -f $file
    fi
done

cd ${projectPath}/Build/
zip -r $source_zipPath UnitySDK

json="{\"text\":{\"content\":\"IOS打包Framework完成,本地临时下载地址：http://${IPV4}/${XCodeFileName}\"},\"msgtype\":\"text\"}"
echo $json
curl -H "Content-Type: application/json" -X POST -d "$json" https://oapi.dingtalk.com/robot/send?access_token=1dd9ef311951334ba9e001f194f78c99ee8b74fff2c56b5f899c1727302f60b8
exit 0

$obsutil cp $source_zipPath obs://wlops/mateurp_ios/$buildType/$XCodeFileName
    
echo downloadUrl: https://wlops.obs.cn-north-4.myhuaweicloud.com/mateurp_ios/$buildType/$XCodeFileName
echo $XCodeFileName upload finish

json="{\"text\":{\"content\":\"IOS打包Framework完成,下载地址 https://wlops.obs.cn-north-4.myhuaweicloud.com/mateurp_ios/${buildType}/${XCodeFileName}\"},\"msgtype\":\"text\"}"
echo $json

curl -H "Content-Type: application/json" -X POST -d "$json" https://oapi.dingtalk.com/robot/send?access_token=1dd9ef311951334ba9e001f194f78c99ee8b74fff2c56b5f899c1727302f60b8
